package app.kotlin_1.adapter

import android.app.IntentService
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.facebook.drawee.view.SimpleDraweeView
import android.widget.TextView
import app.kotlin_1.R
import app.kotlin_1.bean.GameBean

/**
 * Created by 刘智强 on 2017/9/21.
 */
class GalleryAdapter : BaseAdapter {
    private var context: Context? = null
    private var gameList = mutableListOf<GameBean>()


    constructor(context: Context?, gameList: MutableList<GameBean>) : super() {
        this.context = context
        this.gameList = gameList

    }


    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var rootView = LayoutInflater.from(context).inflate(R.layout.item_gallery, parent, false)
        var image = rootView.findViewById(R.id.sdvGameIcon) as SimpleDraweeView
        var name = rootView.findViewById(R.id.tvGameName) as TextView
        image.setImageURI(gameList[position].icon)
        name.text = gameList[position].name
        return rootView
    }

    override fun getItem(position: Int): Any = position
    override fun getItemId(position: Int): Long = position.toLong()
    override fun getCount(): Int = gameList?.size

}